package com.tanhua.server.service;

import com.tanhua.common.utils.UserThreadLocal;
import com.tanhua.common.vo.ErrorResult;
import com.tanhua.dubbo.api.UserLocationApi;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
public class BaiduService {

    @DubboReference(version = "1.0.0")
    private UserLocationApi userLocationApi;


    /**
     * 更新用户位置
     *
     * @param longitude 经度
     * @param latitude  维度
     * @param address   位置名称
     * @return
     */
    public Object updateLocation(Double longitude, Double latitude, String address) {
        Long userId = UserThreadLocal.get();
        Boolean result = this.userLocationApi.updateUserLocation(userId, longitude, latitude, address);
        if (result) {
            return null;
        }
        return ErrorResult.builder()
                .errCode("500").errMessage("用户位置定位失败，请检查手机位置服务是否开启！").build();
    }
}
